<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 正则量词符   *   +  ?  {n} {n,}  {n,m} 

        // 1. * = 重复0次或更多次 >=0
        var rg = /^a*$/
        console.log(rg.test(''));
        console.log(rg.test('a'));
        console.log(rg.test('aa'));
        console.log(rg.test('aaaaa'));
        console.log('------------');
        // 2.+ = 重复一次或更多次 >=1
        var rg1 = /^a+$/
        console.log(rg1.test(''));//false
        console.log(rg1.test('a'));//true
        console.log(rg1.test('aa'));//true
        console.log(rg1.test('aaaaa'));//true
        console.log('------------');
        // 3.? = 重复0次或一次 0||1
        var rg11 = /^a?$/
        console.log(rg11.test(''));//true
        console.log(rg11.test('a'));//true
        console.log(rg11.test('aa'));//false
        console.log(rg11.test('aaaaa'));//false
        console.log('------------');

        // 常有的是这个{n}
        // 4.{n} = 重复n次 
        var rg111 = /^a{3}$/
        console.log(rg111.test(''));//false
        console.log(rg111.test('a'));//false
        console.log(rg111.test('aa'));//false
        console.log(rg111.test('aaa'));//true
        console.log(rg111.test('aaaaa'));//false
        console.log('------------');
         // 5.{n,} = 重复n次或更多次
         var rg111 = /^a{3,}$/  
        console.log(rg111.test(''));//false
        console.log(rg111.test('a'));//false
        console.log(rg111.test('aa'));//false
        console.log(rg111.test('aaa'));//true
        console.log(rg111.test('aaaaa'));//true
        console.log('------------');
        //6.{n,m} = 重复n到m次
         var rg111 = /^a{3,6}$/  
        console.log(rg111.test(''));//false
        console.log(rg111.test('a'));//false
        console.log(rg111.test('aa'));//false
        console.log(rg111.test('aaa'));//true
        console.log(rg111.test('aaaaa'));//true
        console.log(rg111.test('aaaaaa'));//true
        console.log(rg111.test('aaaaaaa'));//false

        






    </script>
</body>
</html>